package com.filepublic.demo.server.handle;

import com.filepublic.demo.common.exception.BaseLogicException;
import com.filepublic.demo.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
public class ExceptionHandle {
    /**
     * 逻辑异常处理器
     * @param baseLogicException
     * @return
     */
    @ExceptionHandler
    public Result logicException(BaseLogicException baseLogicException){
        return Result.error(baseLogicException.getMessage());
    }

    /**
     * 系统异常处理器
     * @param exception
     * @return
     */
    @ExceptionHandler
    public Result systemException(Exception exception){
        System.out.println(exception);
        return Result.error(exception.getMessage());
    }
}









